package 类作为成员变量;

public class Hero {
    private String name;
    private int level;
    //weapon是一个类
    private weapon weapon;

    public void attack() {
        System.out.println("等级为" + level + "的" + name + "正在使用" + weapon.getWeaponname() + "攻击敌方");
    }

    public Hero() {
    }

    public Hero(String name, int level, 类作为成员变量.weapon weapon) {
        this.name = name;
        this.level = level;
        this.weapon = weapon;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public 类作为成员变量.weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(类作为成员变量.weapon weapon) {
        this.weapon = weapon;
    }
}
